//
//  TestRACViewController.m
//  MyDemos
//
//  Created by iMac on 2018/3/16.
//  Copyright © 2018年 iMac. All rights reserved.
//

#import "TestRACViewController.h"
#import "XMView.h"



@interface TestRACViewController ()

@end

@implementation TestRACViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.sBGColor([UIColor whiteColor]);
    
    XMView *view = [[XMView alloc] init];
    view.sFrame(CGRectMake(10, 10, 300, 400)).sBGColor([UIColor grayColor]);
    view.subject = [RACSubject subject];
    self.view.aSubView(view);
    [view.subject subscribeNext:^(UIButton * _Nullable x) {
        x.sBGColor(x.selected ? [UIColor greenColor] : [UIColor redColor]);
    }];
    
    [[view rac_signalForSelector:@selector(btn2Click:)] subscribeNext:^(RACTuple * _Nullable x) {
        UIButton *btn = (UIButton *)x[0];
        btn.selected = !btn.selected;
        btn.sBGColor(btn.selected ? [UIColor greenColor] : [UIColor blueColor]);
    }];
    
}



@end
